/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.inkwell.internet.productregistration.model.impl;

import com.inkwell.internet.productregistration.model.PRRegistration;
import com.inkwell.internet.productregistration.model.PRRegistrationModel;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the PRRegistration service. Represents a row in the &quot;PR_PRRegistration&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.inkwell.internet.productregistration.model.PRRegistrationModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PRRegistrationImpl}.
 * </p>
 *
 * @author NBNguyen
 * @see PRRegistrationImpl
 * @see com.inkwell.internet.productregistration.model.PRRegistration
 * @see com.inkwell.internet.productregistration.model.PRRegistrationModel
 * @generated
 */
public class PRRegistrationModelImpl extends BaseModelImpl<PRRegistration>
	implements PRRegistrationModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a p r registration model instance should use the {@link com.inkwell.internet.productregistration.model.PRRegistration} interface instead.
	 */
	public static final String TABLE_NAME = "PR_PRRegistration";
	public static final Object[][] TABLE_COLUMNS = {
			{ "registrationId", Types.BIGINT },
			{ "prUserId", Types.BIGINT },
			{ "datePurchased", Types.TIMESTAMP },
			{ "howHear", Types.VARCHAR },
			{ "wherePurchased", Types.VARCHAR },
			{ "serialNumber", Types.VARCHAR },
			{ "productId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "groupId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table PR_PRRegistration (registrationId LONG not null primary key,prUserId LONG,datePurchased DATE null,howHear VARCHAR(75) null,wherePurchased VARCHAR(75) null,serialNumber VARCHAR(75) null,productId LONG,companyId LONG,groupId LONG)";
	public static final String TABLE_SQL_DROP = "drop table PR_PRRegistration";
	public static final String ORDER_BY_JPQL = " ORDER BY prRegistration.registrationId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY PR_PRRegistration.registrationId ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.inkwell.internet.productregistration.model.PRRegistration"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.inkwell.internet.productregistration.model.PRRegistration"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.inkwell.internet.productregistration.model.PRRegistration"),
			true);
	public static long DATEPURCHASED_COLUMN_BITMASK = 1L;
	public static long GROUPID_COLUMN_BITMASK = 2L;
	public static long PRUSERID_COLUMN_BITMASK = 4L;
	public static long SERIALNUMBER_COLUMN_BITMASK = 8L;
	public static long REGISTRATIONID_COLUMN_BITMASK = 16L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.inkwell.internet.productregistration.model.PRRegistration"));

	public PRRegistrationModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _registrationId;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setRegistrationId(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _registrationId;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return PRRegistration.class;
	}

	@Override
	public String getModelClassName() {
		return PRRegistration.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("registrationId", getRegistrationId());
		attributes.put("prUserId", getPrUserId());
		attributes.put("datePurchased", getDatePurchased());
		attributes.put("howHear", getHowHear());
		attributes.put("wherePurchased", getWherePurchased());
		attributes.put("serialNumber", getSerialNumber());
		attributes.put("productId", getProductId());
		attributes.put("companyId", getCompanyId());
		attributes.put("groupId", getGroupId());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long registrationId = (Long)attributes.get("registrationId");

		if (registrationId != null) {
			setRegistrationId(registrationId);
		}

		Long prUserId = (Long)attributes.get("prUserId");

		if (prUserId != null) {
			setPrUserId(prUserId);
		}

		Date datePurchased = (Date)attributes.get("datePurchased");

		if (datePurchased != null) {
			setDatePurchased(datePurchased);
		}

		String howHear = (String)attributes.get("howHear");

		if (howHear != null) {
			setHowHear(howHear);
		}

		String wherePurchased = (String)attributes.get("wherePurchased");

		if (wherePurchased != null) {
			setWherePurchased(wherePurchased);
		}

		String serialNumber = (String)attributes.get("serialNumber");

		if (serialNumber != null) {
			setSerialNumber(serialNumber);
		}

		Long productId = (Long)attributes.get("productId");

		if (productId != null) {
			setProductId(productId);
		}

		Long companyId = (Long)attributes.get("companyId");

		if (companyId != null) {
			setCompanyId(companyId);
		}

		Long groupId = (Long)attributes.get("groupId");

		if (groupId != null) {
			setGroupId(groupId);
		}
	}

	@Override
	public long getRegistrationId() {
		return _registrationId;
	}

	@Override
	public void setRegistrationId(long registrationId) {
		_registrationId = registrationId;
	}

	@Override
	public long getPrUserId() {
		return _prUserId;
	}

	@Override
	public void setPrUserId(long prUserId) {
		_columnBitmask |= PRUSERID_COLUMN_BITMASK;

		if (!_setOriginalPrUserId) {
			_setOriginalPrUserId = true;

			_originalPrUserId = _prUserId;
		}

		_prUserId = prUserId;
	}

	@Override
	public String getPrUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getPrUserId(), "uuid", _prUserUuid);
	}

	@Override
	public void setPrUserUuid(String prUserUuid) {
		_prUserUuid = prUserUuid;
	}

	public long getOriginalPrUserId() {
		return _originalPrUserId;
	}

	@Override
	public Date getDatePurchased() {
		return _datePurchased;
	}

	@Override
	public void setDatePurchased(Date datePurchased) {
		_columnBitmask |= DATEPURCHASED_COLUMN_BITMASK;

		if (_originalDatePurchased == null) {
			_originalDatePurchased = _datePurchased;
		}

		_datePurchased = datePurchased;
	}

	public Date getOriginalDatePurchased() {
		return _originalDatePurchased;
	}

	@Override
	public String getHowHear() {
		if (_howHear == null) {
			return StringPool.BLANK;
		}
		else {
			return _howHear;
		}
	}

	@Override
	public void setHowHear(String howHear) {
		_howHear = howHear;
	}

	@Override
	public String getWherePurchased() {
		if (_wherePurchased == null) {
			return StringPool.BLANK;
		}
		else {
			return _wherePurchased;
		}
	}

	@Override
	public void setWherePurchased(String wherePurchased) {
		_wherePurchased = wherePurchased;
	}

	@Override
	public String getSerialNumber() {
		if (_serialNumber == null) {
			return StringPool.BLANK;
		}
		else {
			return _serialNumber;
		}
	}

	@Override
	public void setSerialNumber(String serialNumber) {
		_columnBitmask |= SERIALNUMBER_COLUMN_BITMASK;

		if (_originalSerialNumber == null) {
			_originalSerialNumber = _serialNumber;
		}

		_serialNumber = serialNumber;
	}

	public String getOriginalSerialNumber() {
		return GetterUtil.getString(_originalSerialNumber);
	}

	@Override
	public long getProductId() {
		return _productId;
	}

	@Override
	public void setProductId(long productId) {
		_productId = productId;
	}

	@Override
	public long getCompanyId() {
		return _companyId;
	}

	@Override
	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@Override
	public long getGroupId() {
		return _groupId;
	}

	@Override
	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
			PRRegistration.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public PRRegistration toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (PRRegistration)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		PRRegistrationImpl prRegistrationImpl = new PRRegistrationImpl();

		prRegistrationImpl.setRegistrationId(getRegistrationId());
		prRegistrationImpl.setPrUserId(getPrUserId());
		prRegistrationImpl.setDatePurchased(getDatePurchased());
		prRegistrationImpl.setHowHear(getHowHear());
		prRegistrationImpl.setWherePurchased(getWherePurchased());
		prRegistrationImpl.setSerialNumber(getSerialNumber());
		prRegistrationImpl.setProductId(getProductId());
		prRegistrationImpl.setCompanyId(getCompanyId());
		prRegistrationImpl.setGroupId(getGroupId());

		prRegistrationImpl.resetOriginalValues();

		return prRegistrationImpl;
	}

	@Override
	public int compareTo(PRRegistration prRegistration) {
		long primaryKey = prRegistration.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof PRRegistration)) {
			return false;
		}

		PRRegistration prRegistration = (PRRegistration)obj;

		long primaryKey = prRegistration.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		PRRegistrationModelImpl prRegistrationModelImpl = this;

		prRegistrationModelImpl._originalPrUserId = prRegistrationModelImpl._prUserId;

		prRegistrationModelImpl._setOriginalPrUserId = false;

		prRegistrationModelImpl._originalDatePurchased = prRegistrationModelImpl._datePurchased;

		prRegistrationModelImpl._originalSerialNumber = prRegistrationModelImpl._serialNumber;

		prRegistrationModelImpl._originalGroupId = prRegistrationModelImpl._groupId;

		prRegistrationModelImpl._setOriginalGroupId = false;

		prRegistrationModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<PRRegistration> toCacheModel() {
		PRRegistrationCacheModel prRegistrationCacheModel = new PRRegistrationCacheModel();

		prRegistrationCacheModel.registrationId = getRegistrationId();

		prRegistrationCacheModel.prUserId = getPrUserId();

		Date datePurchased = getDatePurchased();

		if (datePurchased != null) {
			prRegistrationCacheModel.datePurchased = datePurchased.getTime();
		}
		else {
			prRegistrationCacheModel.datePurchased = Long.MIN_VALUE;
		}

		prRegistrationCacheModel.howHear = getHowHear();

		String howHear = prRegistrationCacheModel.howHear;

		if ((howHear != null) && (howHear.length() == 0)) {
			prRegistrationCacheModel.howHear = null;
		}

		prRegistrationCacheModel.wherePurchased = getWherePurchased();

		String wherePurchased = prRegistrationCacheModel.wherePurchased;

		if ((wherePurchased != null) && (wherePurchased.length() == 0)) {
			prRegistrationCacheModel.wherePurchased = null;
		}

		prRegistrationCacheModel.serialNumber = getSerialNumber();

		String serialNumber = prRegistrationCacheModel.serialNumber;

		if ((serialNumber != null) && (serialNumber.length() == 0)) {
			prRegistrationCacheModel.serialNumber = null;
		}

		prRegistrationCacheModel.productId = getProductId();

		prRegistrationCacheModel.companyId = getCompanyId();

		prRegistrationCacheModel.groupId = getGroupId();

		return prRegistrationCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(19);

		sb.append("{registrationId=");
		sb.append(getRegistrationId());
		sb.append(", prUserId=");
		sb.append(getPrUserId());
		sb.append(", datePurchased=");
		sb.append(getDatePurchased());
		sb.append(", howHear=");
		sb.append(getHowHear());
		sb.append(", wherePurchased=");
		sb.append(getWherePurchased());
		sb.append(", serialNumber=");
		sb.append(getSerialNumber());
		sb.append(", productId=");
		sb.append(getProductId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(31);

		sb.append("<model><model-name>");
		sb.append(
			"com.inkwell.internet.productregistration.model.PRRegistration");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>registrationId</column-name><column-value><![CDATA[");
		sb.append(getRegistrationId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>prUserId</column-name><column-value><![CDATA[");
		sb.append(getPrUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>datePurchased</column-name><column-value><![CDATA[");
		sb.append(getDatePurchased());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>howHear</column-name><column-value><![CDATA[");
		sb.append(getHowHear());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>wherePurchased</column-name><column-value><![CDATA[");
		sb.append(getWherePurchased());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>serialNumber</column-name><column-value><![CDATA[");
		sb.append(getSerialNumber());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>productId</column-name><column-value><![CDATA[");
		sb.append(getProductId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = PRRegistration.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			PRRegistration.class
		};
	private long _registrationId;
	private long _prUserId;
	private String _prUserUuid;
	private long _originalPrUserId;
	private boolean _setOriginalPrUserId;
	private Date _datePurchased;
	private Date _originalDatePurchased;
	private String _howHear;
	private String _wherePurchased;
	private String _serialNumber;
	private String _originalSerialNumber;
	private long _productId;
	private long _companyId;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _columnBitmask;
	private PRRegistration _escapedModel;
}